package com.zark.myspringboot.biz.common.bo.impl;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.LoggerFactory;

import org.slf4j.Logger;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.cache.annotation.Cacheable;
import com.zark.myspringboot.biz.common.bo.OperLogBo;
import com.zark.myspringboot.entity.common.mapper.OperLogDoMapperExt;
import com.zark.myspringboot.entity.common.module.OperLogDo;
import com.zark.myspringboot.entity.common.module.OperLogDoExample;
import org.springframework.stereotype.Service;

@Service
public class OperLogBoImpl implements OperLogBo {
	private static final Logger logger = LoggerFactory.getLogger(OperLogBoImpl.class);
	
	@Resource
	private OperLogDoMapperExt operLogDoMapperExt;
	

	@Override
	public List<OperLogDo> queryAll() {
		logger.debug("biz module queryAll operLog debug");
		logger.info("biz module queryAll operLog info");
		logger.warn("biz module queryAll operLog warn");
		logger.error("biz module queryAll operLog error");
		return operLogDoMapperExt.selectByExample(new OperLogDoExample());
	}

	@Override
	public void addOperLog(OperLogDo operLogDo) {
		operLogDoMapperExt.insertSelective(operLogDo);
	}

	@Override
	public void deleteById(Long id) {
		OperLogDo record = new OperLogDo();
		record.setId(id);
		operLogDoMapperExt.deleteByPrimaryKey(record);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateOperLog(OperLogDo operLogDo) {
		operLogDoMapperExt.updateByPrimaryKeySelective(operLogDo);
		System.out.println(1 / 0);
	}

	@Override
	@Cacheable(value = "OPER_LOG")
	public OperLogDo queryById(Long id) {
		return operLogDoMapperExt.selectByPrimaryKey(id);
	}

}
